class Component(object):
    """A component that may be added to a warehouse (e.g. cranes or places)."""
    def __init__(self, parent=None):
        self.parent = None
        if parent is not None:
            self.set_parent(parent)
            
    def set_parent(self, obj):
        self._set_parent(obj)
        if obj is not None:
            obj._add(self)
            
    def _set_parent(self, obj):
        if self.parent is not None:
            self.parent._remove(self)
        self.parent = obj
        
    def deepcopy(self, target):
        if target is None:
            cls = type(self)
            target = cls.__new__(cls)
        target.parent = None
        return target
        
        
